package com.xunji.user.vo.rep;


import com.xunji.user.entity.Org;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;

@ApiModel("组织机构查询")
@Data
public class OrgQueryResponse {

    @ApiModelProperty("id")
    private Integer id;

    @ApiModelProperty("名称")
    private String name;

    @ApiModelProperty("上级组织id")
    private Integer pId;

    @ApiModelProperty("排序")
    private Integer weight;

    @ApiModelProperty("所属调查组")
    private String investigationTeam; // 调查组（备用字段）

    @ApiModelProperty("用户数")
    private Long userCount;

    @ApiModelProperty("创建人")
    private String createdBy;

    @ApiModelProperty("创建时间")
    private LocalDateTime createdTime;


    @ApiModelProperty(value = "子节点")
    private List<OrgQueryResponse> children = new ArrayList<>();

    public static OrgQueryResponse getInstance(Org org) {
        OrgQueryResponse queryResponse = new OrgQueryResponse();
        queryResponse.setId(org.getId());
        queryResponse.setName(org.getName());
        queryResponse.setPId(org.getPId());
        queryResponse.setWeight(org.getWeight());
        queryResponse.setInvestigationTeam(org.getInvestigationTeam());
        queryResponse.setCreatedBy(org.getCreatedBy());
        queryResponse.setCreatedTime(org.getCreatedTime());
        return queryResponse;
    }
}
